namespace SqlWebAdmin
{
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    public partial  class DatabaseToolbar : System.Web.UI.UserControl
    {

        private string selected = "";

        public string Selected 
        {
            get 
            {
                return selected;
            }
            set 
            {
                selected = value.ToLower();
            }
        }

        /// <summary>
        public DatabaseToolbar()
        {
            this.Init += new System.EventHandler(Page_Init);
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            string databaseName = Server.UrlEncode(Request["database"]);

            QueryHyperLink.NavigateUrl              = "../QueryDatabase.aspx?database=" + databaseName;
            TablesHyperLink.NavigateUrl             = "../Tables.aspx?database=" + databaseName;
            PropertiesHyperLink.NavigateUrl         = "../DatabaseProperties.aspx?database=" + databaseName;
            StoredProceduresHyperLink.NavigateUrl   = "../StoredProcedures.aspx?database=" + databaseName;

            switch(selected) 
            {
                case "tables" :
                    TablesTd.Attributes["class"] = "selectedLink";
                    TablesHyperLink.Attributes.Remove("onMouseOver");

                    break;
                case "query" :
                    QueryTd.Attributes["class"] = "selectedLink";
                    QueryHyperLink.Attributes.Remove("onMouseOver");
                    break;
                case "properties" :
                    PropertiesTd.Attributes["class"] = "selectedLink";
                    PropertiesHyperLink.Attributes.Remove("onMouseOver");
                    break;
                case "storedprocedures" :
                    StoredProceduresTd.Attributes["class"] = "selectedLink";
                    StoredProceduresHyperLink.Attributes.Remove("onMouseOver");
                    break;
            }
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            InitializeComponent();
        }

        #region Web Form Designer generated code
         private void InitializeComponent()
        {

        }
        #endregion
    }
}
